package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface UserMapper {

    @Insert("insert into user(openid, name, phone, sex, id_number, avatar, create_time) values (#{openid},#{name},#{phone},#{sex},#{idNumber},#{avatar},#{createTime})")
    public void saveuser(User user);

    @Select("select id from user where openid=#{openid}")
    public Integer getIdByOpenid(String openid);
    @Select("select * from user where openid=#{openid}")
    public User count(String openid);

    @Select("select * from user where id=#{id}")
    public User getById(@Param("id") Long id);


    @Select("select count(id) from user where create_time between #{beginDateTime} and #{endDateTime}")
    Integer getNewUsers(LocalDateTime beginDateTime, LocalDateTime endDateTime);

    @Select("select count(id) from user where create_time <= #{nowTime}")
    Integer getTotalUserInNowTime(LocalDateTime nowTime);

}
